home *** CD-ROM | disk | FTP | other *** search
/ BBS in a Box 3 / BBS in a box - Trilogy III.iso / Files / Tele / Hermes / Hermes Toolbox 0.8 ƒ / HermesToolboxIntf.p < prev    next >
Encoding:
Text File  |  1993-05-25  |  40.8 KB  |  629 lines  |  [TEXT/PJMM]

  1. {-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-}
  2. {This unit is the interface file for the Hermes Toolbox library by Chris Owen}
  3. {The Hermes Toolbox extends the number of procedures and functions that}
  4. {are available when writing externals.  This library is constantly being }
  5. {updated and the most recent version can always be found on Mulligan's Valley}
  6. {at 203-772-4485 or by contacting the author at owen-christopher@yale.edu}
  7. {-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-}
  8.  
  9. {Last modified for Hermes version 2.2 on 5/25/93}
  10. {Version 0.8}
  11.  
  12. unit HermesToolboxIntf;
  13.  
  14. interface
  15.  
  16.     uses
  17.         HermHeaders, MiscIntf;
  18.  
  19.     type
  20.         QDGlobalRecPtr = ^QDGlobalRec;
  21.         QDGlobalRec = record
  22.                 randSeed: Longint;
  23.                 screenBits: BitMap;
  24.                 arrow: Cursor;
  25.                 dkGray: Pattern;
  26.                 ltGray: Pattern;
  27.                 gray: Pattern;
  28.                 black: Pattern;
  29.                 white: Pattern;
  30.                 thePort: GrafPtr;
  31.             end;
  32.  
  33. {•••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••}
  34. {--------------------------------- String Functions ----------------------------------}
  35. {•••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••}
  36.  
  37.     function GetAString (stringGroup, stringNum: integer; addSpaceAtEnd: boolean): str255;
  38. {-----------------------------------------------------------------------------------}
  39. {Get a string from str# resource.  stringGroup is str# resource number and stringNum is}
  40. {number of individual string in that resource.  addSpaceAtEnd will add a single space at end}
  41. {of string if true.  This is useful when getting strings for prompts.}
  42. {-----------------------------------------------------------------------------------}
  43.  
  44.     function SetAString (stringGroup, stringNum: integer; newStr: Str255): OSErr;
  45. {-----------------------------------------------------------------------------------}
  46. {Write a string to a str# resource.  stringGroup is str# resource number and stringNum is}
  47. {number of individual string in that resource. newStr is the string to be saved. Function}
  48. {returns OSErr}
  49. {-----------------------------------------------------------------------------------}
  50.  
  51.     function SetSizeRight (theString: str255; size: integer): str255;
  52. {-----------------------------------------------------------------------------------}
  53. {Make a string a standard width.  theString is either truncated or spaces are added from}
  54. {the left to make the returned string length of size.}
  55. {-----------------------------------------------------------------------------------}
  56.  
  57.     function SetSizeLeft (theString: str255; size: integer): str255;
  58. {-----------------------------------------------------------------------------------}
  59. {Make a string a standard width.  theString is either truncated or spaces are added from}
  60. {the right to make the returned string length of size.}
  61. {-----------------------------------------------------------------------------------}
  62.  
  63.     function Uppercase (theString: str255): str255;
  64. {-----------------------------------------------------------------------------------}
  65. {Make string uppercase.  All characters in theString are raised to uppercase including}
  66. {diacriticals.}
  67. {-----------------------------------------------------------------------------------}
  68.  
  69.     function Lowercase (theString: str255): str255;
  70. {-----------------------------------------------------------------------------------}
  71. {Make string lowercase.  All characters in theString are lowered to lowercase including}
  72. {diacriticals.}
  73. {-----------------------------------------------------------------------------------}
  74.  
  75.     function CapitalizeWords (theString: str255): str255;
  76. {-----------------------------------------------------------------------------------}
  77. {The first character of each word in theString is made uppercase.}
  78. {-----------------------------------------------------------------------------------}
  79.  
  80.     function NumberToString (num: LONGINT): Str255;
  81. {-----------------------------------------------------------------------------------}
  82. {The number num is converted to a string.  This will accept either longInts or integers}
  83. {-----------------------------------------------------------------------------------}
  84.  
  85.     function RealToString (realNum: real; decimals: integer): str255;
  86. {-----------------------------------------------------------------------------------}
  87. {This function converts realNum to a string.  The number will be rounded to the number of}
  88. {decimals specified by decimals.}
  89. {-----------------------------------------------------------------------------------}
  90.  
  91.     function StringToNumber (theString: str255): longInt;
  92. {-----------------------------------------------------------------------------------}
  93. {theString is converted to a number.  Does not check for characters other than numbers}
  94. {in theString}
  95. {-----------------------------------------------------------------------------------}
  96.  
  97.     function TimeToDateString (time: longInt; style: integer): Str255;
  98. {-----------------------------------------------------------------------------------}
  99. {TimeToString will convert time (obtained by using GetTimeDate or TimeNow) to a string}
  100. {using the International Utilities Toolbox.  There are three choices of style.  Using 1 will}
  101. {return a string in the format 11/24/68. Using 2 will return a string in the format}
  102. {Sunday, November 24, 1968. Using 3 will return Sun, Nov 24, 1968.  There are no}
  103. {leading zeros for these formats.  If you need equal length strings use TimeToStr instead}
  104. {-----------------------------------------------------------------------------------}
  105.  
  106.     function TimeToStr (time: longInt; includeTime: boolean; timeOnly: boolean): Str255;
  107. {-----------------------------------------------------------------------------------}
  108. {time (obtained by using GetTimeDate or TimeNow) is converted to a string with the format}
  109. { (MM/DD/YY HH:MM:SS) or (MM/DD/YY) or (HH:MM:SS) depending on the value of includeTime}
  110. {and timeOnly.  The advantage of this function is that it adds leading zeros so the string returned}
  111. {is always the same length.}
  112. {-----------------------------------------------------------------------------------}
  113.  
  114.     function FindAndReplace (theString: Str255; oldString, newString: Str255): str255;
  115. {-----------------------------------------------------------------------------------}
  116. {This function takes theString and replaces the first occurance of oldString with newString}
  117. {and returns the resulting string.}
  118. {-----------------------------------------------------------------------------------}
  119.  
  120.     function FindAndReplaceAll (theString: Str255; oldString, newString: Str255): str255;
  121. {-----------------------------------------------------------------------------------}
  122. {This function takes theString and replaces the all occurances of oldString with newString}
  123. {and returns the resulting string.}
  124. {-----------------------------------------------------------------------------------}
  125.  
  126. {•••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••}
  127. {----------------------------- Hermes Display Functions ------------------------------}
  128. {•••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••}
  129.  
  130.  
  131.     procedure DoCR (numLines: integer; HermSetup: UserXIPtr);
  132. {-----------------------------------------------------------------------------------}
  133. {This procedure will move the cursor down the number of line specified in numLines.  This is}
  134. {just like bCR but you don't have to repeat it so many times and clog up your code.}
  135. {-----------------------------------------------------------------------------------}
  136.  
  137.     procedure Write (theString: str255; HermSetup: UserXIPtr);
  138. {-----------------------------------------------------------------------------------}
  139. {This procedure will simply output theString to the screen.  It uses the built in command in}
  140. {Hermes but I think this is an easier format to call it from.  It uses the current text color.}
  141. {Write will not begin on a new line but start where the last write left off.}
  142. {-----------------------------------------------------------------------------------}
  143.  
  144.     procedure Writeln (theString: str255; HermSetup: UserXIPtr);
  145. {-----------------------------------------------------------------------------------}
  146. {This procedure will simply output theString to the screen.  It uses the built in command in}
  147. {Hermes but I think this is an easier format to call it from.  It uses the current text color.}
  148. {Writeln will  begin on a new line.}
  149. {-----------------------------------------------------------------------------------}
  150.  
  151.     procedure WriteANSI (theString: str255; where: point; color: integer; HermSetup: UserXIPtr);
  152. {-----------------------------------------------------------------------------------}
  153. {WriteANSI will output theString begining at where and in the color specified by color.}
  154. {-----------------------------------------------------------------------------------}
  155.  
  156.     function ListTextRsrc (textID: integer; HermSetup: UserXIPtr): boolean;
  157. {-----------------------------------------------------------------------------------}
  158. {This function willl output to the screen a TEXT resource of number textID.  If the resouce}
  159. {can not be found this returns false.  You must exit the current stage immeadiately after}
  160. {this procedure in order for it to display the text.}
  161. {-----------------------------------------------------------------------------------}
  162.  
  163.     function ListTextFile (filePath: str255; insertPath: boolean; HermSetup: UserXIPtr): boolean;
  164. {-----------------------------------------------------------------------------------}
  165. {This function is mostly to make life a little easier.  Given the path to a file filepath it will}
  166. {output the contents to the screen.  If insertPath is true Hermes will add the path you pass}
  167. {to the path to the Hermes Files folder (ie. you can just pass 'Externals:A textfile'),}
  168. {otherwise it will use filePath as is. If the file isn't found this function will return false. You}
  169. {must exit the current stage immeadiately after this procedure in order for it to display the}
  170. {text.}
  171. {-----------------------------------------------------------------------------------}
  172.  
  173.     procedure Pause (HermSetup: UserXIPtr);
  174. {-----------------------------------------------------------------------------------}
  175. {This procedure will pause the screen until the user hits a key.  It using the built in pause}
  176. {string in Hermes, so whatever the sysop has customized that to will be used.  This}
  177. {procedure must be just before exiting a stage of your external.  Set the stage to where}
  178. {you want to go after the pause, call this and exit the current stage}
  179. {-----------------------------------------------------------------------------------}
  180.  
  181.     procedure ClearScreen (HermSetup: UserXIPtr);
  182. {-----------------------------------------------------------------------------------}
  183. {This procedure will clear the users screen.}
  184. {-----------------------------------------------------------------------------------}
  185.  
  186.     procedure Beep (HermSetup: UserXIPtr);
  187. {-----------------------------------------------------------------------------------}
  188. {This procedure will cause the remote users computer to beep (or flash the menu bar if they}
  189. {have the sound set to 0)}
  190. {-----------------------------------------------------------------------------------}
  191.  
  192. {•••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••}
  193. {----------------------------- File Manipulation Functions -----------------------------}
  194. {•••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••}
  195.  
  196.  
  197.     function FileExists (filePath: str255; var OSResult: OSErr): boolean;
  198. {-----------------------------------------------------------------------------------}
  199. {Given filePath this function will return whether the specified file actually exists.  It also}
  200. {returns the reason for any error in OSResult}
  201. {-----------------------------------------------------------------------------------}
  202.  
  203.     function CreateFile (pathName: string; var theVRefNum: Integer; var theDirID: Integer): OSErr;
  204. {-----------------------------------------------------------------------------------}
  205. {This is a cool one. This function will create a new file with the path pathName.  The cool part}
  206. {is that it will create all the folders along the way. If the path name ends with a : then only}
  207. {the folders will be created.  If you need to start part way down the path you can pass a}
  208. {VRefNum to theVRefNum and a file name or partial path name to thePath.  The function will}
  209. {return the VRefNum and dirID of the file which is created.  If you are using a full path name}
  210. {you MUST pass 0 (zero) for theVRefNum and theDirID.  This is the perfect way to create}
  211. {preference files.  If they don't exist already you can create the whole subdirectory}
  212. {necessary to create them.}
  213. {-----------------------------------------------------------------------------------}
  214.  
  215.     procedure WriteFile (theString: str255; fileRefNum: integer; var OSResult: OSErr);
  216. {-----------------------------------------------------------------------------------}
  217. {WriteFile with write theString to the current location in the file specified by fileRefNum.}
  218. {It will return any error in OSResult.  WriteFile does not add a return at the end of the string}
  219. {-----------------------------------------------------------------------------------}
  220.  
  221.     procedure WritelnFile (theString: str255; fileRefNum: integer; var OSResult: OSErr);
  222. {-----------------------------------------------------------------------------------}
  223. {WritelnFile with write theString to the current location in the file specified by fileRefNum.}
  224. {It will return any error in OSResult.  WriteFile will add a return at the end of the string so}
  225. {that the next string will begin on a new line.}
  226. {-----------------------------------------------------------------------------------}
  227.  
  228.     function TouchFolder (folderPath: str255): OSErr;
  229. {-----------------------------------------------------------------------------------}
  230. {This procedure will chage the last modified date of a folder to the current time and date.}
  231. {This is often useful because it forces the Finder to update all the files in that folder.  Pass}
  232. {it the path to the folder you want to change and it will return any error.}
  233. {-----------------------------------------------------------------------------------}
  234.  
  235.     procedure FlushAllVolumes;
  236. {-----------------------------------------------------------------------------------}
  237. {This procdure will cause all mounted volumes to be immeadiately flushed.  All changes that}
  238. {have been made to files will be written to disk.  This is important because the mac doesn't}
  239. {write to disk until the buffer is full.  If you want to do something especially dangerous or}
  240. {something like shutdown the machine it might be a good idea to call this first.  This will}
  241. {cause a momentary pause in the action if there is lots to be written but no worse than the}
  242. {many pauses that take place when writting something to disk.}
  243. {-----------------------------------------------------------------------------------}
  244.  
  245.     function Readln (refNum: integer; endOfLine: char): str255;
  246. {-----------------------------------------------------------------------------------}
  247. {This function will let you read from a text file.  It is intended to return a single line so it is}
  248. {limited to a returning a string.  refNum is the refNum of the already opened file you want to}
  249. {read from.  endOfLine is the character which ends a line (normally a return). It will return}
  250. {the line as a string and will return a empty string if there is an error. This might be useful}
  251. {if you want to read the BBS list file that Hermes creates.}
  252. {-----------------------------------------------------------------------------------}
  253.  
  254.     procedure ReadText (refNum: integer; data: Handle; endOfLine: char);
  255. {-----------------------------------------------------------------------------------}
  256. {This function is useful if you need to read something larger than a string.  Like Readln you}
  257. {need to pass it a refNum for the open file and the endOfLine character which marks the end}
  258. {of the data you want to read.  With this procedure you must also pass a valid handle to hold}
  259. {the data which is read.  The handle you pass will be resized to the size of the data and will}
  260. {be nil if there is an error.}
  261. {-----------------------------------------------------------------------------------}
  262.  
  263.     function DiskSpaceAvail (volToTest: str255): longInt;
  264. {-----------------------------------------------------------------------------------}
  265. {Given a volume name volToTest this function will return the total amount of free disk space}
  266. {on that volume.}
  267. {-----------------------------------------------------------------------------------}
  268.  
  269.     function CopyFile (source, destination: str255; deleteOriginal: boolean): OSErr;
  270. {-----------------------------------------------------------------------------------}
  271. {CopyFile will copy both the data and resource fork of a file on the path source to the file}
  272. {specified by the path destination.  If true, deleteOriginal will cause the source file to be}
  273. {erased only if the copy was successful.  Any error will be returned in OSErr.}
  274. {-----------------------------------------------------------------------------------}
  275.  
  276.     function GetVolRefNum (thePath: str255): integer;
  277. {-----------------------------------------------------------------------------------}
  278. {Given thePath this function will return the volume reference number of the directory pointed}
  279. {to by that path.  Since pathnames are used so frequently in Hermes you will need this for}
  280. {many of the mac toolbox calls}
  281. {-----------------------------------------------------------------------------------}
  282.  
  283.     function GetPathName (volRefNum: longInt): Str255;
  284. {-----------------------------------------------------------------------------------}
  285. {Given a volume reference number this function will return a path name for that directory.}
  286. {This is useful for converting the result of many of the mac toolbox calls to strings for }
  287. {Hermes}
  288. {-----------------------------------------------------------------------------------}
  289.  
  290.     function GetSystemPath: str255;
  291. {-----------------------------------------------------------------------------------}
  292. {This function returns a pathname to the current system folder.  Good for finding the }
  293. {preference folder or things like Stuffit Engine.}
  294. {-----------------------------------------------------------------------------------}
  295.  
  296.     function DirectoryList (pathtoDir: str255; numtypes: integer; typelist: SFTypelist; var numFiles: integer; HermSetup: UserXIPtr): OSErr;
  297. {-----------------------------------------------------------------------------------}
  298. {This function will write out a list of files in the directory pointed to by pathToDir.  If}
  299. {numTypes is between 1 and 4 it will only list those files which are listed in typeList.  If}
  300. {numTypes is between -1 and -4 it will only list those files in typeList but will also list all}
  301. {folders. Folders are signified by a colon (:) after their name.  If numTypes is greater than}
  302. {4 it will list all files without listing folders.  If it is less than -4 it will list all files and}
  303. {folders in the directory. *Remember that SFTypeList arrays are 0-3 not 1-4* }
  304. {-----------------------------------------------------------------------------------}
  305.  
  306. {•••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••}
  307. {--------------------------- Resource Manipulation Functions --------------------------}
  308. {•••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••}
  309.  
  310.  
  311.     function GetHRMS: eInfoRec;
  312. {-----------------------------------------------------------------------------------}
  313. {This function will get the current externals restriction information that Hermes uses to}
  314. {limit access to the external.  This is useful if you use a main menu command and want to}
  315. {limit that commands use to users who would have access to the external from the }
  316. {external menu.}
  317. {-----------------------------------------------------------------------------------}
  318.  
  319.     procedure SetHRMS (HRMSInfo: eInfoRec);
  320. {-----------------------------------------------------------------------------------}
  321. {This procedure will save the restriction information that Hermes uses to limit access to an}
  322. {external.  No errors are reported but this should be a generally safe procedure.}
  323. {-----------------------------------------------------------------------------------}
  324.  
  325.     function GetRegistration (var bbsName: str255; var registrationNum: longInt; resourceName: resType): boolean;
  326. {-----------------------------------------------------------------------------------}
  327. {This function will let you get saved registration information.  It will retrieve the registration}
  328. {information in bbsName and registration number.  You must pass the resourceName that you}
  329. {previously used to save the information.  See SetRegistration for details.  It will return true}
  330. {if it found the resource and false if it did not.  If it did not find the resource you can create a}
  331. {new one by calling SetRegistration.}
  332. {-----------------------------------------------------------------------------------}
  333.  
  334.     procedure SetRegistration (bbsName: str255; registrationNum: longInt; resourceName: resType);
  335. {-----------------------------------------------------------------------------------}
  336. {This procedure will let you save registration information in your external's resource fork.}
  337. {Pass it the bbsName and registrationNum you want to save.  You also need to pass a}
  338. {resource type name.  This simply 4 letters (ie HRMS).  Each external you write should have}
  339. {its own type though to avoid possible conflicts.  Use the same type you use here as in}
  340. {GetRegistration.}
  341. {-----------------------------------------------------------------------------------}
  342.  
  343.  
  344. {•••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••}
  345. {------------------------------ Sysop External Functions -----------------------------}
  346. {•••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••}
  347.  
  348.  
  349.     function GetCheck (theDialog: dialogPtr; itemNum: integer): boolean;
  350. {-----------------------------------------------------------------------------------}
  351. {Given a dialog pointer theDialog and an item in that dialog, this function will return the }
  352. {current state of the item.  This is for reading check boxes and radio buttons in sysop}
  353. {externals.  Writing this as a function makes it generally easier to use. True is on and }
  354. {false is off.}
  355. {-----------------------------------------------------------------------------------}
  356.  
  357.     procedure SetCheck (theDialog: dialogPtr; itemNum: integer; on: boolean);
  358. {-----------------------------------------------------------------------------------}
  359. {Given a dialog pointer theDialog and an item in that dialog, this function will set the }
  360. {current state of the item to the value of on (true is on and false is off).  This is for setting}
  361. {check boxes and radio buttons in sysop externals.  Writing this as a function makes it }
  362. {generally easier to use. True is on and false is off.}
  363. {-----------------------------------------------------------------------------------}
  364.  
  365.     function GetEditText (theDialog: DialogPtr; itemNum: integer): str255;
  366. {-----------------------------------------------------------------------------------}
  367. {Given a dialog pointer theDialog and an item in that dialog, this function will return the }
  368. {current value an edit text item.  This is for reading edit text fields in sysop externals.}
  369. {Writing this as a function makes it generally easier to use}
  370. {-----------------------------------------------------------------------------------}
  371.  
  372.     procedure SetEditText (theDialog: DialogPtr; itemNum: integer; ETString: str255);
  373. {-----------------------------------------------------------------------------------}
  374. {Given a dialog pointer theDialog and an item in that dialog, this function will set the }
  375. {current value of the edit text item to ETString.  This is for setting edit text fields in }
  376. {sysop externals.  Writing this as a function makes it generally easier to use. }
  377. {-----------------------------------------------------------------------------------}
  378.  
  379.     procedure CenterDialog (theDialog: DialogPtr);
  380. {-----------------------------------------------------------------------------------}
  381. {This procedure takes a dialog (or window) pointer (which you would get from GetNewDialog)}
  382. {and centers it on the screen.  You should make your dialog 'initially invisable' and call this}
  383. {procedure BEFORE calling ShowWindow.  Otherwise the user will see the dialog move across}
  384. {the screen.}
  385. {-----------------------------------------------------------------------------------}
  386.  
  387.     function DoRegistrationDialog (var bbsName: str255; var registrationNum: longInt): boolean;
  388. {-----------------------------------------------------------------------------------}
  389. {This function will put up a small dialog that will allow the sysop to enter basic registration}
  390. {information.  The dialog has two items, one for a BBS name and one for a registration}
  391. {number.  The function stores these two values in bbsName and registrationNum.  The dialog}
  392. {also has two buttons, one for OK and one for cancel.  The function will return true if the OK}
  393. {buttun is hit and false if cancel is hit.  Note that this dialog is modal so it will stop other}
  394. {action on the BBS, but this isn't really a problem since the sysop will  use it rarely. If you}
  395. {use this function you MUST include all the resources included in the file with the same name}
  396. {as this function.  Use ResEdit to copy them to your external's resource file.}
  397. {-----------------------------------------------------------------------------------}
  398.  
  399.     procedure DoTimeDialog (var hour, minute: integer);
  400. {-----------------------------------------------------------------------------------}
  401. {This procedure puts up a dialog similar to that which Hermes uses to enter the time for node}
  402. {start and end time.  It gives the sysop the opportunity to enter time in a manner similar to}
  403. {that used by the Alarm Clock DA and General control panel.  It returns the hour and minute}
  404. {that the sysop entered.  The hour is in 24 hour format so 0 is midnight and 23 is 11 pm.}
  405. {Note that this dialog is modal so it will stop other action on the BBS, but this isn't really a}
  406. {problem since the sysop will  use it rarely. If you use this function you MUST include all}
  407. {the resources included in the file with the same name as this function.  Use ResEdit to copy}
  408. {them to your external's resource file.  There is a text item in this dialog which can be used}
  409. {to prompt the user.  You can either change it with ResEdit or call ParamText and set string}
  410. {number 0 to what you want displayed in that item.}
  411. {-----------------------------------------------------------------------------------}
  412.  
  413.  
  414. {•••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••}
  415. {----------------------------- Process Manager Functions ----------------------------}
  416. {•••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••}
  417.  
  418.  
  419.     function HermesToFront (var oldProcess: ProcessSerialNumber): OSErr;
  420. {-----------------------------------------------------------------------------------}
  421. {This function will make Hermes the front most application.  It returns the process serial}
  422. {number of the application which had been in from in oldProcess.  This is a really rude and}
  423. {not very mac-like thing to do but there are times when it is handy.}
  424. {THIS REQUIRES SYSTEM 7.0 OR LATER - Use System7OrLater below to check.}
  425. {-----------------------------------------------------------------------------------}
  426.  
  427.     function HermesToBack (theProcess: ProcessSerialNumber): OSErr;
  428. {-----------------------------------------------------------------------------------}
  429. {This function will return Hermes to the background after a call to HermesToFront.  You}
  430. {should store the value of oldProcess returned by that function in order to return the old}
  431. {process to the front.}
  432. {THIS REQUIRES SYSTEM 7.0 OR LATER - Use System7OrLater below to check.}
  433. {-----------------------------------------------------------------------------------}
  434.  
  435.     procedure ShutDownMac;
  436. {-----------------------------------------------------------------------------------}
  437. {This procedure will shut the macintosh down and turn off the power on most newer macs.}
  438. {It gives no warning and does not save open documents so it should be used sparingly.}
  439. {-----------------------------------------------------------------------------------}
  440.  
  441.     procedure RestartMac;
  442. {-----------------------------------------------------------------------------------}
  443. {This procedure will restart the macintosh.  It gives no warning and does not save open }
  444. {documents so it should be used sparingly.}
  445. {-----------------------------------------------------------------------------------}
  446.  
  447. {•••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••}
  448. {----------------------------------- User Functions ----------------------------------}
  449. {•••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••}
  450.  
  451.     function FindUserOnline (userNum: integer; var node: integer; HermSetup: UserXIPtr): boolean;
  452. {-----------------------------------------------------------------------------------}
  453. {This function will return true if the user specified  by userNum  is online.  If true then the}
  454. {node that user is on will be returned in node.}
  455. {-----------------------------------------------------------------------------------}
  456.  
  457.     function NewUserAccount (var newUser: UserRec; HermSetup: UserXIPtr): OSErr;
  458. {-----------------------------------------------------------------------------------}
  459. {This function will create a new user on the BBS.  You can pass a full user record or use}
  460. {WriteUser to flesh it out later.  The new user's user number will be passed back in}
  461. {newUser.userNum.}
  462. {-----------------------------------------------------------------------------------}
  463.  
  464.     function DeleteUser (userNum: integer; sysopNote: string; HermSetup: UserXIPtr): OSErr;
  465. {-----------------------------------------------------------------------------------}
  466. {This function will delete the user specified by userNum from the Hermes user list.  Deleted}
  467. {users will have a '•' added to the end of their name.  Optionally you can add a string of up}
  468. {to 40 characters in sysopNote and this function will change the current sysopNote to that}
  469. {string.  This might be usefull to keep track of why the user was deleted.}
  470. {-----------------------------------------------------------------------------------}
  471.  
  472.     function WriteUser (user: UserRec; HermSetup: UserXIPtr): OSErr;
  473. {-----------------------------------------------------------------------------------}
  474. {This function will save the user info contained in UserRec.  It will return any error in writing}
  475. {the info to the HermShared file.  The user info will be written to the account number}
  476. {contained in user.UserNum so if you want to swap user info you need to reset that number.}
  477. {You can change anything in a users record by using the Hermes function 'FindUser' to get}
  478. {a user record, make the necessary changes and then call this function.}
  479. {-----------------------------------------------------------------------------------}
  480.  
  481.     function CheckSub (forumNum, subNum: integer; user: UserRec; HermSetup: UserXIPtr): boolean;
  482. {-----------------------------------------------------------------------------------}
  483. {This function will check whether user has access to the the message base specified by}
  484. {forumNum and subNum.  It returns true if the user does have access.  This funciton will}
  485. {take into consideration if the user has access the forum and if they have the proper security}
  486. {level, restriction and age.}
  487. {-----------------------------------------------------------------------------------}
  488.  
  489. {•••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••}
  490. {---------------------------------- Stuffit Functions ---------------------------------}
  491. {•••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••}
  492.  
  493.     function StuffitExists: boolean;
  494. {-----------------------------------------------------------------------------------}
  495. {This function will check for the existence of the Stuffit Engine.  The Stuffit Engine is}
  496. {supposed to be kept in the Extensions folder inside the System Folder.  It returns true if the}
  497. {Engine is found and false if not.  Most of the other Stuffit Functions call this one but you}
  498. {should still check before using any of them so you can report back to the user.}
  499. {-----------------------------------------------------------------------------------}
  500.  
  501.     function StuffFile (source, destination: str255; deleteOriginal: boolean): OSErr;
  502. {-----------------------------------------------------------------------------------}
  503. {This function will compress a single file using the Stuffit Engine which is part of the Stuffit}
  504. {Deluxe package.  You should pass the path to the file to be compressed in source and where}
  505. {you want the archive to be placed in destination.  If deleteOriginal is true then the file will}
  506. {be deleted after it has been compressed.   This function does not add .sit to the end of the}
  507. {file name so if you are putting the new archive in the same directory you will need to add}
  508. {it yourself in the destination name.  The fuction returns any OSErr that might take place}
  509. {and returns -1 if the user cancels the operation by hitting the stop button in the Stuffit}
  510. {Engine dialog.  Although this function calls StuffitExists you should before calling it in order}
  511. {to report any errors to the user.}
  512. {-----------------------------------------------------------------------------------}
  513.  
  514. {•••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••}
  515. {----------------------------------- Misc Functions ----------------------------------}
  516. {•••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••}
  517.  
  518.     function ParseError (theErr: OSErr; HermSetup: UserXIPtr): str255;
  519. {-----------------------------------------------------------------------------------}
  520. {This function will allow you to translate theErr into a string. It assumes that you have}
  521. {already checked to make sure there actually is an error so you should not call it with error}
  522. {0.}
  523. {-----------------------------------------------------------------------------------}
  524.  
  525.     procedure ReportError (theErr: OSErr; user, log: boolean; HermSetup: UserXIPtr);
  526. {-----------------------------------------------------------------------------------}
  527. {This procedure will translate theErr into a string which can be reported to the user or sysop.}
  528. {If user is true it will print the error string out to the current node.  If log is true it will}
  529. {write the error string to the daily log.  This procedure DOES check the error so you can}
  530. {call it each time you do something that might cause an error and it will not do anything}
  531. {unless the error is other than 0.}
  532. {-----------------------------------------------------------------------------------}
  533.  
  534.     function GetQDGlobals: QDGlobalRec;
  535. {-----------------------------------------------------------------------------------}
  536. {This function will return a QDGlobalRec which is defined above.  This record is identical to}
  537. {the QuickDraw globals which are normally available in an application but not normally}
  538. {available in an external.  Really good stuff can be found here like screenBits.bounds which}
  539. {has the screen size.  This also allows you to use the random call below}
  540. {-----------------------------------------------------------------------------------}
  541.  
  542.     function GetRandom (range: integer): integer;
  543. {-----------------------------------------------------------------------------------}
  544. {This function will return a random number between 1 and range.  When you first call this}
  545. {function it may be a good idea to call it a few times before using its value.  A good way to}
  546. {make it more random might be take the current seconds value and call this function that}
  547. {many times to initialize it.  Without true access to the QDGlobals this function does not}
  548. {properly seed the random call.  After the first time however this call be fine.}
  549. {-----------------------------------------------------------------------------------}
  550.  
  551.     function RandomNumber (range: integer): integer;
  552. {-----------------------------------------------------------------------------------}
  553. {This function will also return a random number but does not rely on the Mac toolbox call. Its}
  554. {your choice.  This may not be as true a random but doesn't suffer from the lack of QD globals}
  555. {that GetRandom does.  If you need to be sure that the first few times you call random are}
  556. {truely random I would use this function rather than the other one.}
  557. {-----------------------------------------------------------------------------------}
  558.  
  559.     function TimeNow: longInt;
  560. {-----------------------------------------------------------------------------------}
  561. {This function returns the current time in seconds since 1/1/1904.  This is just written as}
  562. {a function to make it easier to use.  You can use this with the TimeToDateString to get the}
  563. {current date or time.}
  564. {-----------------------------------------------------------------------------------}
  565.  
  566.     function Sys7OrLater: boolean;
  567. {-----------------------------------------------------------------------------------}
  568. {This function returns whether the current system is 7.0 or later.}
  569. {-----------------------------------------------------------------------------------}
  570.  
  571.     function TrapAvailable (trapNum: integer; tType: TrapType): boolean;
  572. {-----------------------------------------------------------------------------------}
  573. {This function will return whether a trap is available just in case knowing that system 7 is}
  574. {available isn't enough.}
  575. {-----------------------------------------------------------------------------------}
  576.  
  577.     function PlaySound (sndNum: integer; sndName: str255; asynch: boolean; channel: SndChannelPtr): OSErr;
  578. {-----------------------------------------------------------------------------------}
  579. {This function will play a sound on the local machine.  sndNum is the resource number of a }
  580. {'snd ' resource contained in your external.  If you pass a number of 0 the procedure will}
  581. {use the sndName instead.  This may be a better way of making sure that you don't play}
  582. {someone elses sound ;-] If asynch is false the sound will play before control is returned,}
  583. {if true the sound will play asychronously.  If you want to play the sound asynchronously}
  584. {you MUST keep track of a SndChannelPtr in your privates and pass it to this function. This}
  585. {pointer should be intitialized as nil before passing it to PlaySound.  If you set asynch to}
  586. {false you can just pass nil for channel.  I would recommend just passing false and nil unless}
  587. {your sound is really long (which would lock up the BBS until finished).}
  588. {-----------------------------------------------------------------------------------}
  589.  
  590.     function MovedFrom (thePoint: Point; changeAllowed: integer): boolean;
  591. {-----------------------------------------------------------------------------------}
  592. {This function returns whether the mouse has moved more than changeAllowed pixels from}
  593. {thePoint.  Use GetMouse(thePoint) and then LocalToGlobal(thePoint) to get the mouse}
  594. {postion and then this function to decided if it has moved.}
  595. {-----------------------------------------------------------------------------------}
  596.  
  597.     function CheckCard (cardNum: str255; visa, master, amex, discover: boolean): boolean;
  598. {-----------------------------------------------------------------------------------}
  599. {Yea, yea this is getting strange but I needed it so why not make it avaliable.  This function}
  600. {will take a string representing a credit card number and will determine if the number is in}
  601. {the valid format.  Pass true in the remaining varialbes for each type of credit card that is}
  602. {acceptable.  In other words if you pass false for a varialbe that card type will  not be }
  603. {considered valid.  The cardNum string can have spaces although they are not necessary.}
  604. {All spaces will be ignored when evaluating the number.  This function does three things.}
  605. {First, it checks the first number of the card for the credit card type and sees if that type}
  606. {is accepted.  Second, it makes sure that the number is of the proper number of digits for}
  607. {each type.  Third , it does a checksum on the number to see if it is a possible credit card}
  608. {number. This checksum is fairly involved and is not something you would want to do in}
  609. {your head but it is a good way to check cards.  A number which passes these checks is}
  610. {not necessarily valid (ie it may not be assigned to anyone, stolen etc) but this is a good way}
  611. {to screen out fake numbers and mistakes.}
  612. {-----------------------------------------------------------------------------------}
  613.  
  614.     function CheckExpiration (expirationDate: str255): boolean;
  615. {-----------------------------------------------------------------------------------}
  616. {This function will take an expiration date (in the form MM/YY) and return whether this date}
  617. {has passed yet.  With this and CheckCard, assuming the information is given truthfully, you}
  618. {can confirm the validity of a credit card immeadiately.}
  619. {-----------------------------------------------------------------------------------}
  620.  
  621.     procedure SetMouse (newPoint: Point);
  622. {-----------------------------------------------------------------------------------}
  623. {This procedure will set the cursor to newPoint.  Why you would want to do this is beyond me}
  624. {but I had a reason to do so (the user doesn't ever notice).  This is a really rude thing to do}
  625. {and is a good way to have an program which flops (people hate the mouse moving on them)}
  626. {-----------------------------------------------------------------------------------}
  627.  
  628. implementation
  629. end.